package trace

import (
	"github.com/google/uuid"
)

const HeaderKey = "X-Request-Id"
const TraceIDKey = "trace_id"

// Trace trace结构体
type Trace struct {
	Identifier string `json:"trace_id"` // 链路ID
}

// New 创建trace
func New(id string) (t *Trace) {
	if id == "" {
		id = uuid.New().String()
	}

	return &Trace{
		Identifier: id,
	}
}

// ID 获取trace唯一标识符
func (t *Trace) ID() string {
	return t.Identifier
}
